﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3
{
    public partial class WebForm9 : System.Web.UI.Page
    {
        private DataClassesHeaxlthDataContext dc = new DataClassesHeaxlthDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                EmpRegister Semp = (EmpRegister)Session["member"];
                if (Semp == null)
                {
                    Response.Redirect("member.aspx");
                }
                else
                {
                    join();
                }
            }
        }
        public void join()
        {
            EmpRegister Semp = (EmpRegister)Session["member"];
            int empno = Semp.empno;
            var pldetail = this.dc.PolicyRequestDetails
                .Join(dc.PolicyApprovalDetails, pr => pr.requestid, pa => pa.requestid, (pr, pa) => new
                {
                    pr.empno,
                    pr.requestid,
                    pa.policyid
                }
                )
                .Join(dc.policies, pa => pa.policyid, pl => pl.policyid, (pa, pl) => new
                {
                    pa.empno,
                    pa.requestid,
                    pl.policyid,
                    pl.policyname,
                    pl.policydesc,
                    pl.amount,
                    pl.emi
                }
                )
                .Join(dc.PolicyRequestDetails, pl => pl.policyid, pr => pr.policyid, (pl, pr) => new
                {
                    pr.empno,
                    pr.requestid,
                    pr.companyid,
                    pl.policyid,
                    pl.policyname,
                    pl.policydesc,
                    pl.amount,
                    pl.emi
                }
                )
                .Join(dc.CompanyDetails, pr => pr.companyid, cp => cp.companyid, (pr, cp) => new 
                {
                    pr.empno,
                    pr.requestid,
                    pr.companyid,
                    pr.policyid,
                    pr.policyname,
                    pr.policydesc,
                    pr.amount,
                    pr.emi,
                    cp.companyname
                }).Where(a => a.empno.Equals(empno));

            this.GridView1.DataSource = pldetail;
            this.GridView1.DataBind();
        }
    }
}